package com.jfinal.cli.common.controller;

import java.util.Date;
import java.util.Enumeration;

import com.jfinal.core.Controller;
import com.jfinal.kit.Ret;

import cn.hutool.core.date.DateUtil;

/**
 * 模块描述：[控制器基类]
 * 作者：林冰清
 * 日期：2017/6/7.
 */
public class BaseController extends Controller {

    public void renderRetJson() {
        setAttr("timestamp", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));

        Enumeration<String> attrNames = this.getAttrNames();
        Ret ret = Ret.ok();
        while (attrNames.hasMoreElements()) {
            String name = attrNames.nextElement();
            Object value = this.getAttr(name);
            ret.set(name, value);
        }
        super.renderJson(ret);
    }


}
